// pkgTask/components/treeselect-popup/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        ifShow:{
            type:Boolean,
            value:false
        },
        columnItmes:{
            type:Array,
            value:[]
        },
        columnItmesAll:{
            type:Array,
            value:[]
        },
        mainActiveIndex:{
            type:Number,
            value:0
        },
        activeId:{
            type:String
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
       
    },

    /**
     * 组件的方法列表
     */
    methods: {
        onCloseInteractPerson(){
            this.setData({
                ifShow:false 
            })
        },
        changeKeywords(e){
            let that = this
            if (e.detail) {
                let listItemList =that.data.columnItmesAll[that.data.mainActiveIndex].children.filter(item => item.text.indexOf(e.detail) != -1)
                that.data.columnItmes[that.data.mainActiveIndex].children = JSON.parse(JSON.stringify(listItemList))
                that.setData({
                    columnItmes: that.data.columnItmes
                })
            } else {
                that.setData({
                    columnItmes: JSON.parse(JSON.stringify(that.data.columnItmesAll))
                })
            }
        },
        onClickNav(e){
            this.setData({
                mainActiveIndex:e.detail.index
            })
        },
        onClickItem(e){
            let obj={...e.detail,index:this.data.mainActiveIndex}
            this.triggerEvent('okTreeSelect', obj)
            this.setData({
                activeId:e.detail.id,
                ifShow:false
            })            
        }
    }
})
